angular.module('starter.creditService', [])

//信用管理
.factory('CreditService', function($http, $q) {

	return {
  		//查询信用明细
	    getCreditDetail:function(page){
	  		var deferred = $q.defer();
				$http({
					method:'post',
					url:userServerAdr+"/app/getCreditDetail.htm",
					params:{"page":page}
					}).success(function (response) {
					  	deferred.resolve(response);
					}).error(function(data) {
				       deferred.reject();
					});
		   		return deferred.promise;
		},
		//查询收益明细
	    getCreditInComes:function(page){
	  		var deferred = $q.defer();
				$http({
					method:'post',
					url:userServerAdr+"/app/getCreditInComes.htm",
					params:{"page":page}
					}).success(function (response) {
					  	deferred.resolve(response);
					}).error(function(data) {
				       deferred.reject();
					});
		   		return deferred.promise;
		},
		//收益转余额
	    convertIncomeToBalance:function(page){ 
	  		var deferred = $q.defer();
				$http({
					method:'post',
					url:userServerAdr+"/app/convertIncomeToBalance.htm"
					}).success(function (response) {
					  	deferred.resolve(response);
					}).error(function(data) {
				       deferred.reject();
					});
		   		return deferred.promise;
		},
		//领取收益
	    receiveInterest:function(interestId){ 
	  		var deferred = $q.defer();
				$http({
					method:'post',
					url:userServerAdr+"/app/receiveInterest.htm",
					params:{"interestId":interestId}
					}).success(function (response) {
					  	deferred.resolve(response);
					}).error(function(data) {
				       deferred.reject();
					});
		   		return deferred.promise;
		},
		//高级认证接口
		getJuHeStatus:function(customerId){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/getJuHeStatus.htm",
				params:{"customerId":customerId}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//获取信用信息
	  	getCreditLevel:function(){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/getCreditLevel.htm"
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//保存必填类信息
	  	saveGeneralInfo:function(generalInfo){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveGeneralInfo.htm",
				params:{"data":JSON.stringify(generalInfo)}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//查询认证状态
	  	getCreditExamineStatus:function(){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/getCreditExamineStatus.htm"
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//运营商实名认证
	  	saveJuHeMno:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeMno.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//央行征信认证
	  	saveJuHeBankCredit:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeBankCredit.htm",
				params:{"dealCode":authData.dealCode,"username":authData.username,"password":authData.password,"middleAuthCode":authData.middleAuthCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//户籍地址
	  	saveJuHeRegister:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeRegister.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//芝麻信用
	  	saveJuHeZmxy:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeZmxy.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//银行卡消费认证
	  	getBankCardInfo:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/getBankCardInfo.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//公积金认证
	  	saveJuHeFund:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeFund.htm",
				params:{"dealCode":authData.dealCode,"username":authData.username,"password":authData.password,"area":authData.area}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//京东认证
	  	saveJuHeJingDong:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeJingDong.htm",
				params:{"dealCode":authData.dealCode,"loginName":authData.loginName,"passwd":authData.passwd}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//淘宝认证
	  	saveJuHeTaoBao:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeTaoBao.htm",
				params:{"dealCode":authData.dealCode,"loginName":authData.loginName,"password":authData.password}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//婚姻认证
	  	saveJuHeMarrage:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeMarrage.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//社保认证
	  	saveJuHeSecurity:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeSecurity.htm",
				params:{"dealCode":authData.dealCode,"username":authData.username,"password":authData.password,"area":authData.area}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//学位认证
	  	saveJuHeDegree:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeDegree.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//乘机人
	  	saveJuHeFly:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeFly.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//学位认证
	  	saveJuHeDrive:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeDrive.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//专业资格认证
	  	saveJuHeProfession:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeProfession.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//行车证认证
	  	saveJuHeCar:function(authData){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveJuHeCar.htm",
				params:{"dealCode":authData.dealCode}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	},
	  	//人工通道认证
	  	saveSystemMno:function(data){
	  		var deferred = $q.defer();
			$http({
				method:'post',
				url:userServerAdr+"/app/saveSystemMno.htm",
				params:{"dealCode":data.dealCode,"password":data.password}
			}).success(function (response) {
		  		deferred.resolve(response);
			}).error(function(data) {
	        	deferred.reject();
			});
			return deferred.promise;
	  	}
	  
	}

})

;
